import java.util.Scanner;

public class UserText {
    //定义对象方便后续调用都相中的早卓方法
    private static  UserDao userDao=new UserDaoList();
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);

        while(true){
            choose();
int num= scanner.nextInt();
switch (num){
    case 1:loginFace();
           break;
    case 2:
        registerFace();
          break;

    case 3:
        System.out.println("欢迎下次光临");
        System.exit(0);
    default:
        System.out.println("输入有误");
          break;
    case 4:
        showFace();
        break;
}
        }
    }

    private static void showFace() {
        System.out.println("所有注册的用户星系");
        userDao.show();
    }

    private static void registerFace() {
        System.out.println("---------注册界面---------");
        System.out.println("请输入用户名");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        System.out.println("请输入密码");
        String password=scanner.nextLine();
        User user=new User(name,password);
        userDao.register(user);
        System.out.println("注册成功");
    }

    private static void loginFace() {
        System.out.println("---------登陆界面----------------");
        System.out.println("请输入用户名");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        System.out.println("请输入密码");
        String password=scanner.nextLine();

        boolean flag= userDao.login(name,password);
        if(flag){System.out.println("登陆成功");
         GuessGame.start();
        }else {
            System.out.println("登录失败");
        }

    }

    private static void choose() {
        System.out.println("---------欢迎光林---------");
        System.out.println("1。登陆");
        System.out.println("2。注册");
        System.out.println("3。退出");
        System.out.println("4。查看");
        System.out.println("请输入你的选择");
    }
}
